package me.ereach.lambdas;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

public class MainConsumer {
    public static void main(String[] args) {
        List<Integer> list1 = Arrays.asList(1, 2, 3);
        list1.forEach(x -> System.out.println(x));

        List<String> list2 = List.of("abc", "bcd", "cde");
        Consumer<String> print = x -> System.out.println(x);
        Consumer<String> printUpper = x -> System.out.println(x.toUpperCase());
        Consumer<String> printTitle = x -> System.out.println(x.substring(0,1).toUpperCase() + x.substring(1).toLowerCase());
        list2.forEach(print.andThen(printUpper).andThen(printTitle));
    }
}
